package com.yc.spring.test2;

import java.lang.reflect.Field;

public class Stt2 {
	
	public void m1() throws IllegalArgumentException, IllegalAccessException {
		St22 st = new St22();
		Class<? extends St22> Cst = st.getClass();
		Field[] declaredFields = Cst.getDeclaredFields();
		for (Field field : declaredFields) {
			Autowired2 ann = field.getAnnotation(Autowired2.class);
			if (null != ann) {
				field.setAccessible(true);
				field.set(st, new St21());//给成员变量赋值
			}
			
		}
		st.m2();
		
		
	}
	
	public static void main(String[] args) {
		Stt2 st = new Stt2();
		try {
			st.m1();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
